<?php

	$APPID="wx7287a60bb700fd21";
  $secret= "1ef8755f92bebae8ad7bab432ba29cbf";
  $REDIRECT_URI='http://www.txjava.cn/loginServlet';

	header('Content-Type:application/json; charset=utf-8');

	$code = $_POST['code'];
	// 1.获取token
	$token_url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='
	.$APPID.'&secret='.$secret.'&code='.$code.'&grant_type=authorization_code';
	$str = file_get_contents($token_url);
	$str = json_decode($str, JSON_UNESCAPED_UNICODE);

	$access_token = $str['access_token'];
	$openid = $str['openid'];

	// 2.获取用户信息 微信号yizheng369
	$user_url = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$access_token.'&openid='.$openid;
	$userObj = file_get_contents($user_url);
	exit($userObj);
	
?>